<include file="Public:header" />
<div class="container">
	<div class="page-header">
		<h4>{:L('EDIT_THE_SCHEDULE')}</h4>
	</div>
	<div class="row">
		<div class="span12">
			<include file="Public:alert" />
			<form action="{:U('event/edit')}" method="post">
			<input type="hidden" name="event_id" value="{$event.event_id}"/>
			<table class="table table-hover">
				<thead>
					<tr> 
						<td>&nbsp;</td>
						<td <if condition="C('ismobile') neq 1">colspan="3"</if>><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp; <input class="btn" type="button" value="{:L('CANCEL')}" onclick="javascript:history.go(-1)"/></td>
					</tr>
				</thead>
				<tfoot>
					<tr> 
						<td>&nbsp;</td>
						<td <if condition="C('ismobile') neq 1">colspan="3"</if>><input name="submit" class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp; <input class="btn" type="button" value="{:L('CANCEL')}" onclick="javascript:history.go(-1)"/></td>
					</tr>
				</tfoot> 
				<tbody>
					<th <if condition="C('ismobile') eq 1">colspan="2"<else />colspan="4"</if>>{:L('BASIC_INFO')}</th>
					<tr>
						<td class="tdleft" width="15%">{:L('THEME')}</td>
						<td width="35%"><input type="text" name="subject" value="{$event.subject}" class="span3"/></td>
						<if condition="C('ismobile') eq 1"></tr><tr></if>
						<td class="tdleft" width="15%">{:L('OWNER_ROLE')}</td>
						<td  width="35%"><input type="hidden" name="owner_role_id" id="owner_id" value="{$event.owner.role_id}"/><input type="text"  id="owner_name" value="{$event.owner.user_name}" name="owner_name" class="span3"/></td>
					</tr>
					<tr>
						<td class="tdleft">{:L('START_DATE')}</td>
						<td><input type="text" id="start_date" name="start_date" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:&quot;#F{$dp.$D('end_date')||'2020-10-01'}&quot;})" class="span3 Wdate" <if condition="$event['start_date'] gt 0">value="{$event.start_date|date='Y-m-d',###}"</if> /></td>
						<if condition="C('ismobile') eq 1"></tr><tr></if>
						<td class="tdleft">{:L('END_DATE')}</td>
						<td><input type="text" id="end_date" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:&quot;#F{$dp.$D(\'start_date\')}&quot;,maxDate:'2020-10-01'})" name="end_date" class="Wdate span3" <if condition="$event['end_date'] gt 0">value="{$event.end_date|date="Y-m-d",###}"</if> /></td>
					</tr>
					<tr>
						<td class="tdleft">{:L('PLACE')}</td>
						<td><input type="text" id="venue" name="venue" value="{$event.venue}" class="span3"/></td>
						<if condition="C('ismobile') eq 1"></tr><tr></if>
						<td class="tdleft">{:L('SEND_A_NOTIFICATION_EMAIL')}</td>
						<td><input name="send_email" <if condition="$event.send_email eq 1">checked="checked"</if> type="radio" value="1"/>{:L('YES')}<input name="send_email"  <if condition="$event.send_email eq 0">checked="checked"</if> type="radio" value="0"/>{:L('NO')}</td>
					</tr>
					<tr>
						<td class="tdleft">{:L('SELECT_THE_RELEVANT')}</td>
						<td>
							<select name="module" class="span2" onchange="changeContent()" id="select1">
								<option value=""></option>
								<option <if condition="$event['module']['module_name'] eq 'Contacts'">selected="selected"</if> value="contacts">{:L('CONTACTS')}</option>
								<option <if condition="$event['module']['module_name'] eq 'Leads'">selected="selected"</if> value="leads">{:L('LEADS')}</option>
								<option <if condition="$event['module']['module_name'] eq 'Customer'">selected="selected"</if> value="customer">{:L('CUSTOMER')}</option>
								<option <if condition="$event['module']['module_name'] eq 'Business'">selected="selected"</if> value="business">{:L('BUSINESS')}</option>
								<option <if condition="$event['module']['module_name'] eq 'Product'">selected="selected"</if> value="product">{:L('PRODUCT')}</option>
							</select>
							<input type="hidden" id="module_id" name="module_id" value="{$event.module.module_id}" id="select_content"/>
							<input type="text" name="module_name" id="module_name" value="{$event.module.name}"/>
						</td>
						<if condition="C('ismobile') neq 1"><td colspan="2">&nbsp;</td></if>
						
						<!-- <td class="tdleft">是否重复日程</td>
						<td><input name="recurring"  <if condition="$event.recurring eq 1">checked="checked"</if> type="radio" value="1"/>是<input name="recurring"  <if condition="$event.recurring eq 0">checked="checked"</if> type="radio" value="0"/>否</td> -->
					</tr>
					<tr>
						<td class="tdleft">{:L('DESCRIBE')}</td>
						<td <if condition="C('ismobile') neq 1">colspan="3"</if>>
							<textarea rows="6" class="span6" name="description">{$event.description}</textarea>
						</td>
					</tr>
				</tbody>
			</table>
			</form>   
		</div>
	</div>
</div>
<div id="dialog-message" class="hide" title="{:L('SELECT_THE_TASK_OWNER')}">loading...</div>	
<div class="hide" id="dialog-message2" title="{:L('SELECT_CONTACT')}">loading...</div>
<div class="hide" id="dialog-message3" title="{:L('CHOOSE_CLUES')}">loading...</div>
<div class="hide" id="dialog-message4" title="{:L('SELECT_THE_CUSTOMER')}">loading...</div>
<div class="hide" id="dialog-message5" title="{:L('SELECT_BUSINESS')}">loading...</div>
<div class="hide" id="dialog-message6" title="{:L('SELECT_PRODUCT')}">loading...</div>
<script type="text/javascript">
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>

$("#dialog-message").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: {
        "{:L('OK')}": function () {
			var item = $('input:radio[name="owner"]:checked').val();
			var name = $('input:radio[name="owner"]:checked').parent().next().html();
			if(item){
				$('#owner_id').val(item);
				$('#owner_name').val(name);
			}
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
$("#dialog-message2").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: { 
        "{:L('OK')}": function () {
			var item = $('input:radio[name="contacts"]:checked').val();
			var name = $('input:radio[name="contacts"]:checked').parent().next().html();
			$('#module_id').val(item);
			$('#module_name').val(name);
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
$("#dialog-message3").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: { 
        "{:L('OK')}": function () {
			var item = $('input:radio[name="leads"]:checked').val();
			var name = $('input:radio[name="leads"]:checked').parent().next().html();
			var company = $('input:radio[name="leads"]:checked').parent().next().next().html();
			$('#module_id').val(item);
			$('#module_name').val(name+" "+company);
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
$("#dialog-message4").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: { 
        "{:L('OK')}": function () {
			var item = $('input:radio[name="customer"]:checked').val();
			var name = $('input:radio[name="customer"]:checked').parent().next().html();
			$('#module_id').val(item);
			$('#module_name').val(name);
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
$("#dialog-message5").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: { 
        "{:L('OK')}": function () {
			var item = $('input:radio[name="business"]:checked').val();
			var name = $('input:radio[name="business"]:checked').parent().next().html();
			if(item){
				$('#module_id').val(item);
				$('#module_name').val(name);
			}
			
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
$("#dialog-message6").dialog({
    autoOpen: false,
    modal: true,
	width: width,
	maxHeight: 400,
    close: function () {
        $(this).html(""); 
    },
    buttons: { 
        "{:L('OK')}": function () {
			var item = $('input:radio[name="product_id"]:checked').val();
			var name = $('input:radio[name="product_id"]:checked').parent().next().html();
			$('#module_id').val(item);
			$('#module_name').val(name);
            $(this).dialog("close"); 
        },
		"{:L('CANCEL')}": function () {
            $(this).dialog("close");
        }
    },
	position:["center",100]
});
function changeContent(){
	$('#module_id').val("");
	$('#module_name').val("");
}

$(function(){
	$('#owner_name').click(
		function(){
			$('#dialog-message').dialog('open');
			$('#dialog-message').load('{:U("user/listDialog")}');
		}
	);
	$('#module_name').click(
		function(){
			a = $("#select1  option:selected").val();
			if (a == "contacts"){
				$('#dialog-message2').dialog('open');
				$('#dialog-message2').load('{:U("contacts/radioListDialog")}');
			}else if(a == "leads"){
				$('#dialog-message3').dialog('open');
				$('#dialog-message3').load('{:U("leads/listDialog")}');
			}else if(a == "business"){
				$('#dialog-message5').dialog('open');
				$('#dialog-message5').load('{:U("business/listDialog")}');
			}else if(a == "customer"){
				$('#dialog-message4').dialog('open');
				$('#dialog-message4').load('{:U("customer/listDialog")}');
			}else if(a == "product"){
				$('#dialog-message6').dialog('open');
				$('#dialog-message6').load('{:U("product/allProductDialog")}');
			}
		}
	);
});
</script>
<include file="Public:footer" />